﻿using IntoStationSystem.Models;
using System;
using System.Windows.Controls;

namespace IntoStationSystem.Views
{
    /// <summary>
    /// TightenGun.xaml 的交互逻辑
    /// </summary>
    public partial class TightenGunView : UserControl
    {
        public TightenGunView()
        {
            InitializeComponent();
            //if(index == 1)
            //{
            //    tighten = Locator.Instance.Tighten;
            //    //pos = pos1;
            //}
            //else
            //{
            //    tighten = Locator.Instance.Tighten2;
            //    //pos = pos2; 
            //}
            //this.DataContext = tighten;
        }

        //DataPos pos;
        //DataPos pos1 => Locator.Instance.Service.PlcMapping.DataMapping.DataPos.Where(o => o.Desc == "Tighten1").FirstOrDefault();
        //DataPos pos2 => Locator.Instance.Service.PlcMapping.DataMapping.DataPos.Where(o => o.Desc == "Tighten2").FirstOrDefault();

        private void SetProgramDown_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            //byte[] datas = S7.Net.Types.Int.ToByteArray((short)tighten.SelectProgramNum);
            //Locator.Instance.Service.WriteData(pos.Offset + 2, datas);
        }

        private void SetProgramUp_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {

        }

        private void ActionDown_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            int bitOffset = Convert.ToInt32((sender as Button).CommandParameter);
            //Locator.Instance.Service.WriteBool(pos.Offset, bitOffset, true);
        }

        private void ActionUp_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            int bitOffset = Convert.ToInt32((sender as Button).CommandParameter);
            //Locator.Instance.Service.WriteBool(pos.Offset, bitOffset, false);
        }

        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            //tighten.SelectProgramNum = Convert.ToInt32((sender as TextBox).Text);
        }
    }
}
